<?php
########################################################################################
# Empresa :     Tecnopac Informatica;                                                  #
# Autor:        Deiverson Pacheco;                                                     #
# Data Criação: 10/12/2010;                                                            #
########################################################################################
session_start();
header("Cache-control: private");
include_once("../../includes/session.php");


//Linha para formatação de caracteres com acentuação
header("Content-Type: text/html; charset=ISO-8859-1",true);

//======================================================================================
//==> Include obrigatórias no script
//======================================================================================
include_once('../../includes/classes/class.TemplatePower.php');
include_once('../../includes/classes/class.Conexao.php');
include_once('../../includes/classes/class.Geral.php');

//======================================================================================
//==> Inicializar Classes
//======================================================================================
$not  = new Persist;
$not2 = new Persist;
$data = new getData;
$cor  = new ColorTr;
$util = new Util;
$vld  = new ValidarDados;
$sql  = new SqlInjection;

//======================================================================================
//==> Instanciar TemplatePower para juntar o PHP + HTML
//======================================================================================
$tpl  = new TemplatePower('../../html/geral/popup_cadastro.html');
$tpl->prepare();


//======================================================================================
//==> Recebe variaveis de pesquisa
//======================================================================================

$evento = @$_GET['evento'];
$id     = @$_GET['id'];


//======================================================================================
//==> Executa case conforme evento
//======================================================================================

if(isset($evento)){
	switch($evento){
		
		
		case 'editar': {
		  	$id = $sql->tratar($id,10);
			$not->sql = "select id, pessoa, nome_razao, cep, endereco, numero, bairro, cidade, uf, complemento, email, 
			website, doc, residencial, comercial, celular, fax, dt_nascimento, rg, cliente, fornecedor, vendedor, fabrica 
			from cadastro where id = '$id'";
			
			if($not->ler()){
			   $not->ini();
 
			   $tpl->assign('id',$not->id);			   		  
			  
			   if($not->pessoa == 1){
				   $tpl->assign('ck_fisica',' checked="checked"');
			   }else{
				   $tpl->assign('ck_juridica',' checked="checked"');
			   }

			   if($not->cliente == 1){
				   $tpl->assign('ck_cliente',' checked="checked"');
			   }

			   if($not->fornecedor == 1){
				   $tpl->assign('ck_fornecedor',' checked="checked"');
			   }

			   if($not->fabrica == 1){
				   $tpl->assign('ck_fabrica',' checked="checked"');
			   }

			   if($not->vendedor == 1){
				   $tpl->assign('ck_vendedor',' checked="checked"');
			   }
			   
			   $tpl->assign('nome',$not->nome_razao);
			   $tpl->assign('cep',$not->cep);
			   $tpl->assign('logradouro',$not->endereco);
			   $tpl->assign('numero',$not->numero);
			   $tpl->assign('bairro',$not->bairro);
			   $tpl->assign('cidade',$not->cidade);
			   $tpl->assign('uf',$not->uf);
			   $tpl->assign('complemento',$not->complemento);
			   $tpl->assign('email',$not->email);
			   $tpl->assign('site',$not->website);			   
			   $tpl->assign('doc',$not->doc);
			   $tpl->assign('rg',$not->rg);
			   $tpl->assign('residencial',$not->residencial);
			   $tpl->assign('comercial',$not->comercial);
			   $tpl->assign('celular',$not->celular);
			   $tpl->assign('fax',$not->fax);
			   $tpl->assign('dtnas',$data->getDataFormatada($not->dt_nascimento));


			}
			


		break;
		}
		
		
	}
}


//======================================================================================
//==> Enviar página unificada PHP + HTML
//======================================================================================
$tpl->showUnAssigned( false );  // para debug. na hora de publicar, setar para false
$tpl->printToScreen();
?>